import { appHub } from './user'
import { ElNotification } from 'element-plus'
import { h } from 'vue'

/** 处理邮件通知 */
const handleEmailNotification = (subject, abstract, sender) => {
    ElNotification({
        title: "📩 新邮件通知",
        message: h("div", { style: "cursor: pointer;" }, [
            h("strong", subject),
            h("p", { style: "font-size: 12px; color: #666; margin-top: 4px;" }, abstract),
            h("p", { style: "font-size: 12px; color: #888;" }, `来自: ${sender}`)
        ]),
        position: "bottom-right",
        duration: 5000,
        onClick: () => {
            console.log("用户点击了邮件通知:", subject);
            // 可以执行跳转或其他操作
        }
    });
    console.log("接收邮件通知:", subject);
};



/**接收邮件监听 */
export const addReciveEmailListener = () => {
    appHub.on("ReceiveEmail", handleEmailNotification);
}
